# -*- coding: utf-8 -*-
# @时间      : 2025/4/11 下午3:04
# @作者      : hhh
import requests,pytest,random

ph = str(random.randint(1370000001, 1399999999))

#准备一个data列表 列表中存储测试数据 用小字典 方便调用 可以迭代
data = [
    {'ph': ph+"1", 'pwd': 'a123456', 'msg': '注册成功'},        #正例
    {'ph': '1361371383', 'pwd': 'a123456', 'msg': '非有效手机号码'},    #手机号 少一位
    {'ph': '136137138355', 'pwd': 'a123456', 'msg': '非有效手机号码'},  #手机号 多一位
    {'ph': ph+"2", 'pwd': '1234567', 'msg': '密码格式错误'},     #密码排列组合错误
    {'ph': ph+"3", 'pwd': None, 'msg': '请输入密码'},            #密码为空
]

@pytest.mark.parametrize('case',data)
def test_register(case):
    url = 'https://mall.deyunce.com/api/account/register'
    head = {
        "authorization": "Basic ZGV5dW5jZTo4MjgxMjM=",
        "content-type": "application/json"
    }
    body = {"mobile":case['ph'],"password":case['pwd'],"code":"","client":5}
    res = requests.post(url=url,headers=head,json=body)
    print(res.json())
    assert res.json()['msg'] == case['msg']

